#ifndef __LUA_H__
#define __LUA_H__

extern "C"
{
#include "src/lua.h"
};


#ifdef _DEBUG
#define LUAASSERT(p) if(!p){*(int*)0=0;}
#else
#define LUAASSERT(p) 
#endif

class CLua;
class LuaCheckStack
{
public:
	LuaCheckStack(CLua* L,int add);
	~LuaCheckStack();
public:
	CLua* Lua;
	int StartStack;
};

// CheckStack
#define CHECKSTACK
#ifdef CHECKSTACK
#define CHECKSTACK_BEGIN(L,A) LuaCheckStack __luacheckstack(L,A)
#else
#define CHECKSTACK_BEGIN(L,A)
#endif // CHECKSTACK


#define CHECKTYPE(T,L,I) if(!LuaStack::StackValue<T>::Check(L,I)){CLuaPrint::LuaError(ELR_VALUEWRONGTYPE); return 0;}



class CLua
{
public:
	CLua(void);
	~CLua(void);
public:
	void InitLua();
	bool LoadFile(char *filename);
	void ReleaseLua();

//stack
public:
	#include "LuaCApi.h"

protected:
private:
	lua_State* mLuaState;
};



#endif


